#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void
MainWindow::on_actionStart_Capture_triggered()
{
    if (!mCapture.isOpened()) {

        if (!mCapture.open (0)) {
            return;
        }

        startTimer(50);

    }
}

void
MainWindow::timerEvent(QTimerEvent *event)
{
    cv::Mat image;

    mCapture >> image;

    ui->openCVviewer->showImage(image);
}


void MainWindow::on_actionStop_Capture_triggered()
{
    mCapture.release();
}

void MainWindow::on_pushButton_clicked()
{
    this->on_actionStart_Capture_triggered();
}

void MainWindow::on_pushButton_2_clicked()
{
    this->on_actionStop_Capture_triggered();
}
